//试炼之所结束信息
client.on('trialInfo', function(msg) {
  if ($('#mainContent #trial').html()) {
    loadTrial()
  }
})

//野外boss被击杀信息
client.on('fieldBossKill', function(msg) {
  $('.attackFieldBoss').css('display', 'none')
  $('.battleInfo').css('display', 'none')
  $('.enterDevilCave').css('display', 'block')
  showMessage('守护之地boss被' + msg.name + '玩家击杀')
})

//野外boss出现
client.on('noticeFieldBoss', function(msg) {
  $('.attackFieldBoss').css('display', 'block')
  $('.battleInfo').css('display', 'block')
  $('.enterDevilCave').css('display', 'none')
  $('.attackFieldBoss .progress-bar').css('width', '100%')
  showMessage('守护之地boss出现了')
})

//野外boss出现
client.on('fieldBossDamageRank', function(msg) {
  var damageArray = msg.damageArray
  $('.attackFieldBoss .progress-bar').css('width', msg.hpPer / 100 + '%')
  $('.damageRank').empty()
  for (var i = damageArray.length - 1; i >= 0; i--) {
    var info = damageArray[i]
    $('.damageRank').append((damageArray.length - i) + '    ' + info[2] + '<div style="text-align:right">' + info[1] + '伤害</div>')
  }
})

client.on('newMail', function(msg) {
  var content = msg.content
  if (content) {
    showMessage(content)
  } else {
    showMessage('你有新的邮件,请到邮箱查看')
  }
})

client.on('arenaChallenge', function(msg) {
  if (msg.result === 0) {
    showMessage(msg.p1 + '在竞技场挑战你,你获胜了')
  } else {
    showMessage(msg.p1 + '在竞技场挑战你,你战败了')
  }

  if ($('#mainContent #arena').html()) {
    loadArena()
  }
})

client.on('lvlup', function(msg) {
  var lvl = msg.lvl
  if (lvl === 2) {
    showMessage('你升到2级了')
  } else if (lvl === 3) {
    showMessage('你升到3级了,试炼之所,守护之地开启.')
  } else if (lvl === 4) {
    showMessage('你升到4级了,竞技场开启')
  }
})
